package deno2;

import java.util.InputMismatchException;
import java.util.Scanner;

public class TestFinally {
    public static int getData(){
        Scanner sc = new Scanner(System.in);
        try{

            int data = sc.nextInt();
            int ret = 10/data;
            System.out.println("ret的值是: " + ret);

        }catch (InputMismatchException e){
            e.printStackTrace();
        }finally {
            sc.close();
            System.out.println("finally中代码");
        }
        System.out.println("try-catch-finally之后代码");

        return 0;
    }
    public static void main(String[] args) {
        int data = getData();
        System.out.println(data);
    }
}


   /* public static void main(String[] args) {
        try {
            func();
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
        }
        System.out.println("after try catch");
    }
    public static void func() {
        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }
*/


    /*public static void main(String[] args) {
    func();
    System.out.println("after try catch");
}
    public static void func() {
        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }
*/